package com.bawei.lookfor2204a.view.fragment.guanchang

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import com.bawei.lookfor2204a.model.FindLiveListBean
import com.bawei.lookfor2204a.model.HttpUtils
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers

/**
 * 作者：赵亮
 * 时间：2024/10/15 16:54
 * 功能：广场模块的View Model
 */
class GuangChangViewModel : ViewModel() {

    // 查询直播列表的数据容器
    val findLiveListBeanSuccess = MutableLiveData<FindLiveListBean>()
    fun findLiveList(
        liveType: Int,
        page: Int,
        size: Int
    ) {
        HttpUtils.HttpUtils.apiService.findLiveList(liveType, page, size)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe {
                findLiveListBeanSuccess.postValue(it)
            }
    }

    // 轮播图
    val bannerSuccess = MutableLiveData<FindLiveListBean>()
    fun banner(
        liveType: Int,
        page: Int,
        size: Int
    ) {
        HttpUtils.HttpUtils.apiService.findLiveList(liveType, page, size)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe {
                bannerSuccess.postValue(it)
            }
    }

}